@using BTCPayServer.Abstractions.TagHelpers
@using BTCPayServer.Client
@using Microsoft.AspNetCore.Mvc.TagHelpers
@model PairingModel
@{
    var store = Context.GetStoreData();
    Layout = store is null ? "_LayoutWizard" : "_Layout";
    ViewData.SetLayoutModel(new(nameof(StoreNavPages.Tokens), StringLocalizer["Pairing Permission"]));
}

@if (store is null)
{
    @section Navbar {
        <button type="button" class="cancel" onclick="history.back()">
            <vc:icon symbol="cross" />
        </button>
    }
}
<form asp-action="Pair" method="post" permissioned="@Policies.CanModifyStoreSettings">
    <div class="sticky-header">
        @if (store != null)
        {
            <nav aria-label="breadcrumb">
                <ol class="breadcrumb">
                    <li class="breadcrumb-item">
                        <a asp-action="ListTokens" asp-route-storeId="@store.Id" text-translate="true">Access Tokens</a>
                    </li>
                    <li class="breadcrumb-item">
                        <a asp-action="CreateToken" asp-route-storeId="@store.Id" text-translate="true">Create Token</a>
                    </li>
                    <li class="breadcrumb-item active" aria-current="page">@ViewData["Title"]</li>
                </ol>
                <h2>@ViewData["Title"]</h2>
            </nav>
        }
        else
        {
            <h2>@ViewData["Title"]</h2>
        }
		<button id="page-primary" type="submit" class="btn btn-primary mt-3" title="@StringLocalizer["Approve this pairing demand"]" text-translate="true">Approve</button>
    </div>
    <partial name="_StatusMessage" />
    <div class="row">
        <div class="col-sm-8 col-md-6 @(store is null ? "mx-auto" : "")">
            <table class="table table-hover">
                <tr>
                    <th>Label</th>
                    <td class="text-end">@Model.Label</td>
                </tr>
                <tr>
                    <th>SIN</th>
                    <td class="text-end">@Model.SIN</td>
                </tr>
            </table>
            @if (store is null)
            {
                <div class="form-group">
                    <label asp-for="StoreId" class="form-label">Pair To Store</label>
                    <select asp-for="StoreId" asp-items="@(new SelectList(Model.Stores, "Id", "Name"))" class="form-select"></select>
                    <span asp-validation-for="StoreId" class="text-danger"></span>
                </div>
            }
            else
            {
                <input asp-for="StoreId" type="hidden" />
            }
            <input type="hidden" name="pairingCode" value="@Model.Id"/>
        </div>
    </div>
</form>
